import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
  { ignores: ['dist/*', 'node_modules/*', '**/*.md', '.vscode', '.idea', 'bin'] },
  {
    extends: [
      js.configs.recommended,
      ...tseslint.configs.recommended,
      'eslint-config-prettier',
      'prettier'
    ],
    files: ['**/*.{ts,tsx}'],
    languageOptions: {
      ecmaVersion: 2020,
      globals: globals.browser
    },
    plugins: {
      'react-hooks': reactHooks,
      'react-refresh': reactRefresh
    },
    rules: {
      'prettier/prettier': 'error', // 将 Prettier 规则作为 ESLint 报错
      ...reactHooks.configs.recommended.rules,
      'no-multi-spaces': 'warn', // 禁止使用多个空格
      semi: ['warn', 'never'], // 禁止尾部使用分号
      indent: ['warn', 2, { SwitchCase: 1 }], // 要求使用JS一致缩进2个空格
      'react-refresh/only-export-components': ['warn', { allowConstantExport: true }]
    }
  }
)
